package net.gz01.wallet.web.model;

import com.jfinal.plugin.activerecord.Page;
import net.gz01.wallet.common.ZOSearchCondition;
import net.gz01.wallet.common.ZOSqlHelper;
import net.gz01.wallet.web.model.base.BaseHetongConfig;

import java.util.List;

@SuppressWarnings("serial")
public class HeTongConfig extends BaseHetongConfig<HeTongConfig> {
    public static final HeTongConfig dao = new HeTongConfig().dao();

    public List<HeTongConfig> selectAll(){
        return super.find("select * from hetong_config");
    }

    public Page<HeTongConfig> search(ZOSearchCondition sc){
        int pageNumber = sc.page.getPageNum();
        int pageSize = sc.page.getNumPerPage();

        ZOSqlHelper sql = new ZOSqlHelper(" from hetong_config WHERE 1 = 1");
        sql.like("title", sc.get("code"));
        sql.like("sign_keyword", sc.get("name"));
        sql.equals("enable", sc.getBoolean("enable"));
        return super.paginate(pageNumber, pageSize, "select *", sql.toString(),sql.getParams());
    }

    public HeTongConfig selectById(String id){
        return super.findFirst("select * from hetong_config where id=" + id);
    }

    public HeTongConfig selectByEnable(){
        return super.findFirst("select * from hetong_config where enable=1");
    }

}
